<?php
namespace Admin\Controller;

use Think\Controller;

/**
 * 查看所有新闻，及查看新闻详情
 * @author zhanglei<firenzelei@163.com>
 * @time   2015/03/13
 */
class IndexController extends Controller {
    
    /**
     * 显示所有新闻
     */
    public function index()
    {
        $news = M("news");
        $data = $news -> field(array('id,title')) -> select();
        $this -> assign('data',$data);
        $this-> display();
    }
	
    /**
     * 查看单条新闻的详情
     */
    public function detail(){
        if(isset($_GET['id']) && is_numeric($_GET['id']))
        {
            $id = $_GET['id'];                //新闻的id
            $news = M("news");
            $data = $news -> where(array("id=$id")) -> field(array('id,name,title,information')) -> find();
            $this -> assign('data',$data);
            $this-> display();
        }else{
            dump('非法操作，请重试');
        }
    }
}